package com.android.baseconfig.constact;

/*
 * -----------------------------------------------------------------
 * Copyright © 2016年 clife. All rights reserved.
 * Shenzhen H&T Intelligent Control Co.,Ltd.
 * -----------------------------------------------------------------
 * File: AppGlobalHost.java
 * Create: 2016/6/20 19:59
 * Author: uuxia
 * App网络访问地址类
 */
public class AppGlobalHost {
    /**
     * 开发环境
     **/
    public static String DEBUG_HOST = "http://www.poss.cn:8080";
    /**
     * 测试环境
     **/
    public static String TEST_HOST = "https://siot-test.supor.com";

    public static String RELEASE_COMM_HOST = "https://sda-community.supor.com/h5/#";
    /**
     * 正式环境
     **/
    public static String RELEASE_HOST = "";

    private static String host = TEST_HOST;

    private static String communityHost = RELEASE_COMM_HOST;

    public static String getHost() {
        return host;
    }

    /**
     * 默认https
     **/
    public static void setHost(String url) {
        setHostHttps(url);
    }

    public static void setHostHttp(String url) {
        if (url.startsWith("https://") || url.startsWith("http://")) {
            host = url;
            host = host.replaceAll("https://", "http://");
        } else {
            host = "http://" + url;
        }
    }

    public static void setHostHttps(String url) {
        if (url.startsWith("https://") || url.startsWith("http://")) {
            host = url;
            host = host.replaceAll("http://", "https://");
        } else {
            host = "https://" + url;
        }
    }

    public static String getHttp() {
        if (host.startsWith("https://") || host.startsWith("http://")) {
            host = host.replaceAll("https://", "http://");
        } else {
            host = "http://" + host;
        }
        return host;
    }

    public static String getHttps() {
        if (host.startsWith("https://") || host.startsWith("http://")) {
            host = host.replaceAll("http://", "https://");
        } else {
            host = "https://" + host;
        }
        return host;
    }


    public static String getCommHost() {
        return communityHost;
    }

    /**
     * 默认https
     **/
    public static void setCommHost(String url) {
        setCommHostHttps(url);
    }

    public static void setNormalCommHost(String url) {
        communityHost = url;
    }

    public static void setCommHostHttp(String url) {
        if (url.startsWith("https://") || url.startsWith("http://")) {
            communityHost = url;
            communityHost = communityHost.replaceAll("https://", "http://");
        } else {
            communityHost = "http://" + url;
        }
    }

    public static void setCommHostHttps(String url) {
        if (url.startsWith("https://") || url.startsWith("http://")) {
            communityHost = url;
            communityHost = communityHost.replaceAll("http://", "https://");
        } else {
            communityHost = "https://" + url;
        }
    }

    public static String getCommHttp() {
        if (communityHost.startsWith("https://") || communityHost.startsWith("http://")) {
            communityHost = communityHost.replaceAll("https://", "http://");
        } else {
            communityHost = "http://" + communityHost;
        }
        return communityHost;
    }

    public static String getCommHttps() {
        if (communityHost.startsWith("https://") || communityHost.startsWith("http://")) {
            communityHost = communityHost.replaceAll("http://", "https://");
        } else {
            communityHost = "https://" + communityHost;
        }
        return communityHost;
    }
}
